package com.baizhi.service.impl;

import com.baizhi.annotation.InsertAnnotation;
import com.baizhi.dao.LogDao;
import com.baizhi.entity.Log;
import com.baizhi.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class LogServiceImpl implements LogService {

    @Autowired(required = false)
    private LogDao logDao;

    @Override
    @InsertAnnotation
    public Map selectAll(int page, int limit, String logType) {
        if(logType!=null && !logType.equals("")){
            logType="%"+logType+"%";
        }else {
            logType=null;
        }
        int offset=(page-1)*limit;
        List<Log> logs = logDao.selectAll(offset, limit, logType);
        int count=logDao.selectCount(logType);
        Map map=new HashMap();
        map.put("data",logs);
        map.put("count",count);
        map.put("code",0);
        map.put("msg","");
        return map;
    }



}
